<template>
	<view class="page">
		<view class="calendar-container">
			<uni-calendar 
			:insert="true" 
			:lunar="true" 
			:selected="calendar" 
			@monthSwitch="changeMonth"
			@change="getMonthDay"></uni-calendar>
		</view>
		<uni-title type="h1" align="center" title="工作内容安排"></uni-title>
		<view class="textarea">
			<text>
				{{txt}}
			</text>
		</view>
	</view>
</template>

<script>
	import uniCalendar from '@/components/uni-calendar/uni-calendar.vue';
	import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue'
	import uniTitle from '@/components/uni-title/uni-title.vue';
	export default {
		components: {
			uniCalendar,
			uniTitle,
			uniNavBar
		},
		data() {
			return {
				date:'',
				calendar: [],
				txt:''
			}
		},	
		onLoad(){
			let that = this;
			let now = new Date();
			let year = now.getFullYear();
			let month = now.getMonth() + 1;
			month = month < 10 ? '0' + month : month;
			let date = now.getDate();
			date = date < 10 ? '0' + date : date;
			let yyyy_mm_dd = year + '-' + month + '-' + date
			that.showDay(yyyy_mm_dd)
		},
		methods: {
			changeMonth(e) {
				let that = this;
				let year = e.year;
				let month = e.month;
			},
			getMonthDay(e){
				let that = this;
				that.date = e.fulldate;
				that.showDay(that.date);
			},
			showDay(date){
				let that = this;
				that.ajax(that.url.getArrange,'POST',{
					createTime:date
				},function(resp){
					let data = resp.data.data;
					let message = '暂无'
					if(data==null){
						that.txt = message;
					}else{
						that.txt = data.content;
					}
				});
			}
		}
	}
</script>

<style lang="less">
@import url('work_date.less');
</style>
